#from game.actions.models import action
from game.actions.actionRequest import actionRequest

class combatActionRequest(actionRequest):

    def __init__(self, action, caller, target, combatInstance):
        """action is the action to perform. Caller is the combatant performing the action."""
        """Target is the combatant having the action applied. combatInstance is the combat where the action is."""
        self.combat = combatInstance
        self.caller = caller
        self.target = target
        self.action = action
    
    def validateRequest(self):
        if self.caller != self.combat.currentCombatant or self.combat.currentState == 1:
            return False
        if not self.caller.individual.hasAction(self.action):
            return False
        if self.caller.individual.mpLeft < self.action.mpNeeded:
            return False
        return True
    
    def getResult(self):
        results = actionRequest.getResults(self)
        self.caller.addTick(self.action.speed)
        return results